package com.project.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.bean.AreaBean;
import com.project.dao.AreaDao;
import com.project.service.AreaService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * 区域
 */

@Service
@Transactional
public class AreaServiceImpl extends ServiceImpl<AreaDao, AreaBean> implements AreaService {
    /**
     * 分页显示所有区域信息
     * @param pageNo
     * @param pageSize
     * @return
     */
    @Override
    public IPage<AreaBean> findAllArea(int pageNo, int pageSize) {
        Page<AreaBean> page = new Page<>(pageNo,pageSize);
//        IPage<AreaBean> iPage = this.page(page);
        return this.baseMapper.findAllArea(page);
    }

    /**
     * 添加新区域
     * @param area
     */
    @Override
    public void addArea(AreaBean area) {
        this.baseMapper.insert(area);

    }

    /**
     * 根据区域名称、林种、小班模糊查询区域信息
     * @param areaName
     * @param areaSeed
//     * @param clas
     * @return
     */
    @Override
    public IPage<AreaBean> findName(int pageNo,int pageSize,
                                    String areaName, String areaSeed, String className) {
        Page<AreaBean> page = new Page<>(pageNo,pageSize);
//        IPage<AreaBean> iPage = this.page(page);
        return this.baseMapper.findName(page,areaName,areaSeed,className);
    }

}
